package com.chenfan.magic.service.impl;

import com.chenfan.common.vo.UserVO;
import com.chenfan.magic.annation.DbType;
import com.chenfan.magic.config.UserVoConstextHolder;
import com.chenfan.magic.dao.ShopComMapper;
import com.chenfan.magic.entity.ShopCom;
import com.chenfan.magic.enums.DatabaseType;
import com.chenfan.magic.service.ShopComService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.List;
import java.util.stream.Collectors;

/**
 * @author liuming
 * @date 2022-01-08 17:44
 */
@Service
public class ShopComServiceImpl implements ShopComService {

    @Autowired
    private ShopComMapper shopComMapper;

    /**
     * 查询店铺id列表
     *
     * @return
     */
    @Override
    @DbType(type = DatabaseType.clickhouse_251)
    public List<Long> getShopIds() {
        UserVO userVo = UserVoConstextHolder.getUserVo();
        List<ShopCom> list = shopComMapper.getList(userVo.getUserId(), shopComMapper.getUserViewClosedShop(userVo.getUserId()));
        return list.stream().map(x -> x.getShopId()).collect(Collectors.toList());
    }
}
